﻿@*
    生成者：admin
    生成时间：5/7/2021 下午 5:21:12
    代码由代码生成器自动生成，更改的代码可能被进行替换
    界面如需更改，建议直接将内容剪切到自己的文件内，保留此空白文件
    日志列表
*@
@page "/Log/Index"
@using Caviar.Models
@inherits IndexComponentBase<ViewLog>
@namespace Caviar.AntDesignPages.Pages.SysLog
<CavTableTemplate TData="ViewLog"
                  DataSource="DataSource"
                  PageSize="PageSize"
                  PageIndex="PageIndex"
                  Total="Total"
                  Buttons="Buttons"
                  Query="Query"
                  ViewModelFields="ViewModelFields"
                  PageIndexChanged="PageIndexChanged"
                  RowCallback="RowCallback"
                  Loading="Loading"
                  FuzzyQueryCallback="FuzzyQueryCallback"
                  GetTableItems="GetTableItems">
</CavTableTemplate>

@code{

    public RenderFragment GetTableItems(ViewModelFields fields)
    {
        RenderFragment render = null;
        var context = fields.Value;
        switch (fields.TypeName.ToLower())
        {
            case "elapsed":
                render =@<Column Title="@fields.DisplayName" TData="double" Width="@fields.Width">
        @{
            var obj = context.GetObjValue(fields.TypeName);
            if (obj != null)
            {
                var value = (double)obj;
                if (value < 1500)
                {
                    <Tag Color="green">@value</Tag>
                }
                else
                {
                    <Tag Color="orange">@value</Tag>
                }
            }
        }
    </Column>;
           break;
           case "status":
        render =@<Column Title="@fields.DisplayName" TData="int" Width="@fields.Width">
        @{
            var obj = context.GetObjValue(fields.TypeName);
            if (obj != null)
            {
                var value = (int)obj;
                if (value == HttpState.OK)
                {
                    <Tag Color="green">@value</Tag>
                }
                else
                {
                    <Tag Color="red-inverse">@value</Tag>
                }
            }
        }
    </Column>;
                        break;
                    case "loglevel":
        render =@<Column Title="@fields.DisplayName" TData="string" Width="@fields.Width">
    @{
        var obj = context.GetObjValue(fields.TypeName);
        if (obj != null)
        {
            var value = (CavLogLevel)obj;
            var index = (int)value;
            var str = fields.EnumValueName[index];
            switch (value)
            {
                case CavLogLevel.Trace:
                case CavLogLevel.Debug:
                case CavLogLevel.Information:
                    <Tag Color="green">@str</Tag>
                    break;
                case CavLogLevel.Warning:
                    <Tag Color="orange-inverse">@str</Tag>
                    break;
                case CavLogLevel.Error:
                    <Tag Color="red-inverse">@str</Tag>
                    break;
                case CavLogLevel.Critical:
                    <Tag Color="purple-inverse">@str</Tag>
                    break;
                case CavLogLevel.None:
                    break;
                default:
                    break;
            }
        }
    }
</Column>;
                        break;
                    default:
                        break;
                }
                return render;
            }
}